<template>
	<view class="patrolDetails_container">
		<view class="" style="height: 160rpx;">
			<view class="mail_List fixed z_ninetynine">
				<view class="mail" style="font-weight: 700;">
					<view class="order">巡检详情</view>
				</view>
			</view>
			<view class="icon fixed z_ninetynine">
				<u-icon name="arrow-left" color="#fefefe" size="40" @click="navigateBack"></u-icon>
			</view>

		</view>
		<!-- 执行信息1 -->
		<view class="" v-for="(item,index) in members" :key='index'>
			<view class="data_Statistics" style="padding: 44rpx 24rpx 0 ;" v-show="patrol">
				<text style="font-weight: 700; font-size: 30rpx; color: #c4c4c4;">丨</text><text
					style="font-weight: 700; font-size: 30rpx;">执行信息</text>
			</view>
			<view class="card" style="position: relative; padding: 0 42rpx;" v-show="patrol">
				<u-form :model="form" ref="uForm">
					<u-form-item label="执行人:">
						<u-input v-model="form.Reporter"
							placeholder-style="color: #000; text-align: right; font-weight: 600;"
							:placeholder="item.staffName" :clearable="false" :disabled="true" />
					</u-form-item>
					<u-form-item label="执行状态:">
						<u-input v-model="form.address"
							placeholder-style="color: #000; text-align: right; font-weight: 600;" placeholder="待执行"
							:clearable="false" :disabled="true" v-if="particulars.patrolStatus=='1'" />
						<u-input v-model="form.address"
							placeholder-style="color: #000; text-align: right; font-weight: 600;" placeholder="未接单"
							:clearable="false" :disabled="true" v-if="particulars.patrolStatus=='0'" />
					</u-form-item>
					<image src="/static/workOrder/Group801.png" mode=""
						style=" position: absolute;top: 20rpx; left: 236rpx; width: 280rpx; height: 280rpx;"
						v-if="particulars.patrolStatus=='1'">
					</image>
					<image src="/static/workOrder/Group804.png" mode=""
						style=" position: absolute;top: 20rpx; left: 236rpx; width: 280rpx; height: 280rpx;"
						v-if="particulars.patrolStatus=='0'">
					</image>
				</u-form>
			</view>
		</view>
		<!-- 执行信息2 -->
		<view class="data_Statistics" style="padding: 44rpx 24rpx 0 ;">
			<text style="font-weight: 700; font-size: 30rpx; color: #c4c4c4;">丨</text><text
				style="font-weight: 700; font-size: 30rpx;">执行信息</text>
		</view>
		<view class="card" style="position: relative; padding: 0 42rpx;">
			<u-form :model="form" ref="uForm">
				<u-form-item label="执行人:">
					<u-input v-model="form.Reporter"
						placeholder-style="color: #000; text-align: right; font-weight: 600;"
						:placeholder="particulars.staffName" :clearable="false" :disabled="true" />
				</u-form-item>
				<u-form-item label="执行状态:">
					<u-input v-model="form.address"
						placeholder-style="color: #000; text-align: right; font-weight: 600;" placeholder="待接单"
						:clearable="false" :disabled="true" v-if="particulars.patrolStatus=='0'" />
					<u-input v-model="form.address"
						placeholder-style="color: #000; text-align: right; font-weight: 600;" placeholder="待执行"
						:clearable="false" :disabled="true" v-if="particulars.patrolStatus=='1'" />
					<u-input v-model="form.address"
						placeholder-style="color: #000; text-align: right; font-weight: 600;" placeholder="完成"
						:clearable="false" :disabled="true" v-if="particulars.patrolStatus=='2'" />
					<u-input v-model="form.address"
						placeholder-style="color: #000; text-align: right; font-weight: 600;" placeholder="超时完成"
						:clearable="false" :disabled="true" v-if="particulars.patrolStatus=='3'" />
				</u-form-item>
				<u-form-item label="接单时间:">
					<u-input v-model="form.address"
						placeholder-style="color: #000; text-align: right; font-weight: 600;"
						:placeholder="particulars.createTime" :clearable="false" :disabled="true" />
				</u-form-item>
				<image src="/static/workOrder/Group801.png" mode=""
					style=" position: absolute;top: 60rpx; left: 236rpx; width: 280rpx; height: 280rpx;"
					v-if="particulars.patrolStatus=='1'">
				</image>
				<image src="/static/workOrder/Group689.png" mode=""
					style=" position: absolute;top: 60rpx; left: 236rpx; width: 280rpx; height: 280rpx;"
					v-if="particulars.patrolStatus=='0'">
				</image>
			</u-form>
		</view>
		<!-- 巡检信息 -->
		<view class="data_Statistics" style="padding: 28rpx 24rpx 0 ;">
			<text style="font-weight: 700; font-size: 30rpx; color: #c4c4c4;">丨</text><text
				style="font-weight: 700; font-size: 30rpx;">巡检信息</text>
		</view>
		<view class="card" style="padding: 0 42rpx;">
			<u-form :model="form" ref="uForm">
				<u-form-item label="设备名称:">
					<u-input v-model="form.Reporter"
						placeholder-style="color: #000; text-align: right; font-weight: 600;"
						:placeholder="particulars.name" :clearable="false" :disabled="true" />
				</u-form-item>
				<u-form-item label="设备编号:">
					<u-input v-model="form.address"
						placeholder-style="color: #000; text-align: right; font-weight: 600;"
						:placeholder="particulars.indexCode" :clearable="false" :disabled="true" />
				</u-form-item>
				<u-form-item label="巡检周期:">
					<u-input v-model="form.address"
						placeholder-style="color: #000; text-align: right; font-weight: 600;"
						:placeholder="particulars.cycle" :clearable="false" :disabled="true" />
				</u-form-item>
				<u-form-item label="巡检日期:">
					<u-input v-model="form.address"
						placeholder-style="color: #000; text-align: right; font-weight: 600;"
						:placeholder="particulars.InspectionDate" :clearable="false" :disabled="true" />
				</u-form-item>
				<u-form-item label="设备地址:">
					<u-input v-model="form.address"
						placeholder-style="color: #000; text-align: right; font-weight: 600;"
						:placeholder="particulars.deviceAddress" :clearable="false" :disabled="true" />
				</u-form-item>
				<u-form-item label="巡检要点:" label-position="top">
					<u-input v-model="form.describe" placeholder-style="color: #000; text-align: left;"
						:placeholder="particulars.content" :clearable="false" :disabled="true" />
					<!-- 					<u-input v-model="form.describe" placeholder-style="color: #000; text-align: left;"
						placeholder="2、访春园区Y32#2单元水表箱处是否清洁干净" :clearable="false" :disabled="true" />
					<u-input v-model="form.describe" placeholder-style="color: #000; text-align: left;"
						placeholder="3、访春园区Y32#2单元水表箱处是否清洁干净" :clearable="false" :disabled="true" /> -->
				</u-form-item>
				<u-form-item label="负责人:">
					<u-input v-model="form.chargeName"
						placeholder-style="color: #000; text-align: right; font-weight: 600;"
						:placeholder="particulars.chargeName" :clearable="false" :disabled="true" />
				</u-form-item>
				<!-- 巡更点1异常上报 -->
				<!-- 					<view class="position" style="display: flex;padding: 10rpx 0 20rpx 31rpx;border-bottom: 1px solid #f6f7f9;" v-if="flag4">
						<text style="color: red;line-height: 70rpx;">异常上报: </text>
						<u-input v-model="form.chargePerson" :custom-style="{'margin-left': '21rpx'}"
							placeholder="请输入异常情况" style="flex: 2;" />
					</view> -->
				<view class=""
					style="display: flex;justify-content: space-evenly; color: green; padding: 20rpx 0 36rpx;border-bottom: 1px solid #f6f7f9;"
					v-if="flag4">
					异常
				</view>
				<!-- 巡更点1按钮 -->
				<view class=""
					style="display: flex;justify-content: space-evenly; padding: 20rpx 0 36rpx; border-bottom: 1px solid #f6f7f9;"
					v-if="image2==3">
					<u-button type="error" :plain="true" size="mini" shape="circle" @click="reporting4">异常上报</u-button>
					<u-button type="success" size="mini" shape="circle" @click="normal">正常</u-button>
				</view>
				<!-- 巡更点1无异常 -->
				<view class=""
					style="display: flex;justify-content: space-evenly; color: green; padding: 20rpx 0 36rpx;border-bottom: 1px solid #f6f7f9;"
					v-if="abnormality3==2">
					无异常
				</view>
				<u-form-item label="负责人:">
					<u-input v-model="form.address"
						placeholder-style="color: #000; text-align: right; font-weight: 600;"
						:placeholder="particulars.chargeName" :clearable="false" :disabled="true" />
				</u-form-item>
			</u-form>
		</view>
		<view class="button">
			<u-button type="primary" style="flex: 1;" @click="resolved" v-if="image!=3">转交</u-button>
			<!-- <u-button type="success" style="flex: 1;" @click="Approved" v-if="image==1">接单</u-button> -->
			<u-button type="success" style="flex: 1;" @click="implement" v-if="image==2">执行</u-button>
			<u-button type="success" style="flex: 1;" @click="Submit" v-if="image==3">提交</u-button>
		</view>
		<u-popup v-model="show" mode="center" width="626rpx" height="430rpx" border-radius="20">
			<view
				style="height: 54rpx; line-height: 54rpx; font-weight: 600; color: #a1a1a1; background-color: #fbfbfb; text-align: center;">
				巡检提示</view>
			<view class="work_Order">
				<view class="work_Order_top"></view>
				<view class="work_Order_bottom" style="margin-top: 10rpx;">巡检完成！</view>
			</view>
		</u-popup>
		<!-- 弹框 -->
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// form表单
				form: {
					Reporter: '',
					title: '',
					address: '',
					describe: '',
					chargePerson: '',
					Executor: '',
					Maintenance: '',
					end: ''
				},
				// 演示地址，请勿直接使用
				action: 'http://www.example.com/upload',
				show: false,
				image: 2,
				image2: 1,
				flag4: false,
				abnormality3: 1,
				// 巡检待执行Id
				patrolId: '',
				// 车辆详情
				particulars: '',
				// 审核通过
				staff: '',
				// 执行信息1的数据
				members: '',
				// 控制执行信息1的显示与隐藏
				patrol: false,
				orderId: ''
			}
		},
		onLoad(val) {
			this.loginId = uni.getStorageSync("setModel")
			console.log(val)
			if (val.patrolId) {
				this.patrolId = val.patrolId
				// 巡检待执行详情
				this.getListVehicleByIds()
			}
			// this.loading()
		},
		methods: {
			// 巡检待执行详情
			getListVehicleByIds() {
				this.$http.get('Patrol/ExaminePatrol', {
					patrolId: this.patrolId
				}).then(res => {
					this.particulars = res.data.patrol
					this.orderId = res.data.patrol.orderId
					let patrolMembers = res.data.patrolMembers
					if (patrolMembers.length != 0) {
						this.members = patrolMembers
						this.patrol = true
					}
					console.log(res, '待接单详情')
					// this.owners = res.data
				})
			},
			// 转交
			resolved() {
				this.show = true
			},
			// 接单
			// Approved() {
			// 	this.image = 2
			// },
			// 执行
			implement() {
				this.image = 3
				this.image2 = 3
			},
			// 提交
			Submit() {
				if (this.form.chargePerson != '' || this.abnormality3 == 2) {
					this.show = true
				}
				this.$http.put('PatrolStatus/updatePatrolOrderStatusSuccess', {
					orderId: this.orderId
				}).then(res => {
					// this.particulars=res.data
					console.log(res, '提交')
					uni.navigateBack()
					// this.owners = res.data
				})
			},
			// 异常上报
			reporting4() {
				this.$http.put('Patrol/updateDeviceStatus', {
					orderId: this.orderId
				}).then(res => {
					console.log(res)
					if(res.code==200) {
						this.$refs.uToast.show({
							title: res.msg,
						})
				this.flag4 = true
				this.image2 = 1
					} else {
						this.$refs.uToast.show({
							title: res.msg,
						})
					}
					console.log(res, '点击异常上报触发')
					// this.owners = res.data
				})
			},
			// 正常按钮
			normal() {
				this.abnormality3 = 2
				this.image2 = 1
			}
		}
	}
</script>

<style lang="scss" scoped>
	.patrolDetails_container {
		.mail_List {
			overflow: hidden;
			width: 100%;
			background-color: #f2f2f2;

			.mail {
				padding: 10rpx 0;
				// margin-top: 96rpx;
				color: #999999;
				font-size: 40rpx;
				background-color: #e5e5e5;
			}

			.order {
				text-align: center;
			}
		}

		/deep/.card {
			.u-form-item--left {
				flex: unset !important;
				width: unset !important;
			}

			.frequency {
				display: flex;

				// justify-content: space-between;
				u-input {
					flex: 2;
				}
			}

			.example {
				display: flex;
				margin-left: 67rpx;
			}

			.u-form-item--right {
				margin-left: 31rpx;
			}

			button {
				width: 170rpx;
				border-radius: 100rpx !important;
			}
		}

		.icon {
			position: absolute;
			top: 18rpx;
			// top: 114rpx;
			left: 20rpx;
		}

		.second_card {
			.u-cell {
				padding: 18rpx 32rpx;

				/deep/.u-cell__value {
					color: #333333;
					font-weight: 600;
				}
			}

			/deep/.uni-card__content {
				padding: 16rpx 24rpx;
			}
		}

		/deep/button {
			border-radius: unset !important;
		}

		.uni-border[data-v-19622063]:after {
			border: unset;
		}

		/deep/.uni-border.data-v-19622063:after {
			border: unset;
		}

		.slot-btn__hover {
			background-color: rgb(235, 236, 238);
		}

		.button {
			display: flex;
			position: fixed;
			left: 0;
			right: 0;
			bottom: 0;
			// margin-top: 200rpx;
			border-radius: 14rpx;
			overflow: hidden;
			z-index: 9;

			.u-btn {
				border-radius: unset;
			}
		}

		.work_Order {
			margin-top: 60rpx;
			text-align: center;

			.work_Order_top {
				width: 168rpx;
				height: 168rpx;
				margin: 0 auto;
				background-color: #e5e5e5;
				border-radius: 50%;
			}
		}
	}
</style>
